package com.fancymusic.controller;


import com.fancymusic.mongoEntity.MongoMusic;
import com.fancymusic.mongoService.MongoMusicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class MongoMusicController {

    @Autowired
    private MongoMusicService mongoMusicService;


    /**
     * 查询所有音乐数据
     * @return
     */
    @GetMapping("/findAllMongoMusic")
    public List<MongoMusic> findAllMongoMusic(){
        return mongoMusicService.findAll();
    }


    /**
     * 保存音乐数据
     * @param mongoMusic
     * @return
     */
    @PostMapping("/savaMongoMusic")
    public String savaMongoMusic(@RequestBody MongoMusic mongoMusic){
        return mongoMusicService.saveObj(mongoMusic);
    }


}
